home *** CD-ROM | disk | FTP | other *** search
/ Aminet 44 / Aminet 44 (2001)(GTI - Schatztruhe)[!][Aug 2001].iso / Aminet / util / misc / ReportPlus.lha / reportplus / source / f2.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-06-25  |  31.4 KB  |  1,060 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <clib/exec_protos.h>
  4. #include <intuition/intuition.h>
  5. #include <clib/intuition_protos.h>
  6. #include <libraries/gadtools.h>
  7. #include <clib/gadtools_protos.h>
  8. #include <graphics/gfx.h>
  9. #include <clib/graphics_protos.h>
  10.  
  11. #include <clib/alib_protos.h>
  12. #include <ctype.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #include "rp.h"
  16.  
  17. #include <reaction/reaction.h>
  18. #include <gadgets/texteditor.h>
  19. #include <clib/texteditor_protos.h>
  20. #include <pragmas/texteditor_pragmas.h>
  21.  
  22. #define MAINTYPES   15
  23. #define CATEGORIES 339
  24. struct
  25. {   ULONG start, end;
  26. } offsets[MAINTYPES + 1] =
  27. {   16,  26, // biz
  28.     27,  47, // comm
  29.     48,  73, // demo
  30.     74,  90, // dev
  31.     91,  97, // disk
  32.     98, 105, // docs
  33.    106, 120, // games
  34.    121, 132, // gfx
  35.    133, 135, // hard
  36.    136, 140, // info
  37.    141, 150, // misc
  38.    151, 260, // mods
  39.    261, 264, // mus
  40.    265, 305, // pix
  41.    306, 316, // text
  42.    317, 339  // util
  43. };
  44.  
  45. AGLOBAL struct AminetStruct aminet;
  46.  
  47. // from rp.c
  48. IMPORT ABOOL                fillwindows, react;
  49. IMPORT SBYTE                page;
  50. IMPORT TEXT                 IOBuffer[LONGESTFIELD + 1],
  51.                             aslresult[MEDFIELD + 1],
  52.                             string[VLONGFIELD + 1];
  53. IMPORT ULONG                offset;
  54. IMPORT struct NewGadget     Gadget;
  55. IMPORT struct SharedStruct  shared;
  56. IMPORT struct Gadget       *BU99_Right,
  57.                            *BU99_TextEditor,
  58.                            *PrevGadPtr;
  59. IMPORT struct Window*       MainWindowPtr;
  60. IMPORT struct Library*      TextEditorBase;
  61.  
  62. MODULE void updateaminetgadgets(void);
  63. MODULE void readaminetgadgets(void);
  64.  
  65. #define GID_2_TE1 0 // Text Editor 1 (long description)
  66. #define GIDS_2    GID_2_TE1
  67.  
  68. MODULE struct List   *MainTypeListPtr   = NULL,
  69.                      *SubTypeListPtr    = NULL;
  70. MODULE struct Gadget *ST21_Short        = NULL,
  71.                      *ST21_Uploader     = NULL,
  72.                      *ST21_Author       = NULL,
  73.                      *ST21_Requires     = NULL,
  74.                      *ST21_Version      = NULL,
  75.                      *ST21_Distribution = NULL,
  76.                      *ST21_Replaces     = NULL,
  77.                      *LV21_MainType     = NULL,
  78.                      *LV21_SubType      = NULL,
  79.                      *TE21_Long         = NULL,
  80.                      *gadgets[GIDS_2 + 1];
  81.  
  82. MODULE struct
  83. {   STRPTR name;
  84.     STRPTR desc;
  85. } category[CATEGORIES + 1] =
  86. { // all (0)
  87. "biz",   "Business software",
  88. "comm",  "Communications",
  89. "demo",  "Gfx and sound demos",
  90. "dev",   "Development software",
  91. "disk",  "Disk/Harddisk tools",
  92. "docs",  "Text documents",
  93. "game",  "Games",
  94. "gfx",   "Graphics",
  95. "hard",  "Hardware",
  96. "info",  "General FTP information",
  97. "misc",  "Miscellaneous",
  98. "mods",  "Music modules",
  99. "mus",   "Musical software",
  100. "pix",   "Pictures",
  101. "text",  "Text related",
  102. "util",  "Utilities",
  103. // biz (16)
  104. "cloan", "Cloanto software & support",
  105. "dbase", "Data base software",
  106. "demo",  "Demo versions of commercial software",
  107. "dkg",   "DarkAge software & support",
  108. "dopus", "Directory Opus files",
  109. "haage", "Haage & Partner software & support",
  110. "misc",  "Misc business type soft",
  111. "patch", "Commercial software patches",
  112. "p5",    "phase5 software & support",
  113. "swood", "Softwood products",
  114. "titan", "Titan Computer software",
  115. // comm (27)
  116. "ambos", "AmBoS (BBS) related",
  117. "amiex", "Ami-Express BBS related",
  118. "bbs",   "BBS programs",
  119. "cnet",  "CNET BBS related",
  120. "dlg",   "DLG BBS related",
  121. "fido",  "FIDO software",
  122. "irc",   "Internet Relay Chat software",
  123. "mail",  "Mailing soft",
  124. "maxs",  "MaxsBBS related",
  125. "mebbs", "MEBBSNet BBS related",
  126. "misc",  "Misc communications",
  127. "mmgr",  "MailManager related",
  128. "net",   "Networking",
  129. "news",  "Newsreaders",
  130. "tcp",   "AmiTCP networking",
  131. "term",  "Terminal programs",
  132. "thor",  "Thor mail/news system",
  133. "ums",   "Universal Message System",
  134. "uucp",  "UUCP software",
  135. "www",   "World Wide Web software",
  136. "xeno",  "Xenolink BBS related",
  137. // demo (48)
  138. "40k",   "40K intros",
  139. "aga",   "Demos requiring AGA chipset",
  140. "bse",   "Belgian Scene Event files",
  141. "disk",  "Demos on diskettes",
  142. "ecs",   "Demos for the ECS chip set",
  143. "euro",  "Euro demos in file form",
  144. "file",  "Single file demos",
  145. "funet", "From the Funet collection",
  146. "intro", "Intros",
  147. "mag",   "Demo coder magazines",
  148. "mega",  "Euro demos requiring floppies",
  149. "slide", "Image oriented demos",
  150. "sound", "Sound oriented demos",
  151. "sp96",  "Saturne Party 96 demos",
  152. "ta95",  "Demos from The Assembly 95",
  153. "ta96",  "Demos from The Assembly 96",
  154. "ta97",  "Demos from The Assembly 97",
  155. "tg93",  "The Gathering 1993 demos",
  156. "tg95",  "The Gathering 1995 demos",
  157. "tg96",  "The Gathering 1996 demos",
  158. "tg97",  "The Gathering 1997 demos",
  159. "tp92",  "Demos from The Party 92",
  160. "tp94",  "Demos from The Party 94",
  161. "tp95",  "Demos from The Party 95",
  162. "tp96",  "Demos from The Party 96",
  163. "track", "Trackmos",
  164. // dev (74)
  165. "amos",  "AMOS BASIC compiler",
  166. "asm",   "Assembly language related",
  167. "basic", "BASIC language related",
  168. "c",     "C language related",
  169. "cross", "Cross development",
  170. "debug", "Debugging software",
  171. "e",     "E language related",
  172. "gcc",   "GNU C compiler",
  173. "gg",    "Geek Gadgets GNU software",
  174. "gui",   "GUI builders",
  175. "lang",  "Various languages",
  176. "m2",    "Modula-2 related",
  177. "misc",  "Misc development software",
  178. "moni",  "Monitors/disassemblers",
  179. "mui",   "MagicUserInterface related",
  180. "obero", "Oberon related software",
  181. "src",   "Tutorial sources",
  182. // disk (92)
  183. "bakup", "Backup software",
  184. "cache", "Disk caching",
  185. "cdrom", "CD-ROM related software",
  186. "misc",  "Various disk related tools",
  187. "moni",  "Disk monitors",
  188. "optim", "Disk optimizers",
  189. "salv",  "Disk recovery software",
  190. // docs (99)
  191. "anno",  "Announcement documents",
  192. "etext", "Project Gutenberg books",
  193. "help",  "Help on various issues",
  194. "hyper", "Hypertext documents",
  195. "lists", "Lists and tables",
  196. "mags",  "Magazines",
  197. "misc",  "Various documents",
  198. "rview", "Amiga product reviews",
  199. // game (107)
  200. "2play", "2 and more player games",
  201. "actio", "Action games",
  202. "board", "Board games",
  203. "data",  "Data files for games",
  204. "demo",  "Demos of commercial games",
  205. "gag",   "Gag programs",
  206. "hint",  "Game hint documents",
  207. "jump",  "Jump-n-run games",
  208. "misc",  "Miscellaneous games",
  209. "patch", "Patches for games",
  210. "role",  "Role, adventure games",
  211. "shoot", "Shoot-em-up games",
  212. "text",  "Text based adventures",
  213. "think", "Mind games",
  214. "wb",    "Workbench games",
  215. // gfx  (122)
  216. "3d",    "3D graphics software",
  217. "3dobj", "3D objects",
  218. "aga",   "AGA chip set software",
  219. "board", "Custom gfx board software",
  220. "conv",  "Gfx conversion tools",
  221. "edit",  "Paint programs",
  222. "fract", "Fractals and Mandelbrots",
  223. "ifx",   "ImageFX related files",
  224. "misc",  "Misc graphics software",
  225. "pbm",   "Pbm+ gfx conversion",
  226. "show",  "Image/anim displayers",
  227. "x11",   "Amiga X-Windows",
  228. // hard (134)
  229. "drivr", "Drivers for hardware",
  230. "hack",  "Selfmade hardware",
  231. "misc",  "Misc hardware related files",
  232. // info (137)
  233. "adt",   "Machine readable filelists",
  234. "index", "Various Aminet index files",
  235. "sites", "Info on other FTP sites",
  236. "start", "Beginner information",
  237. "stats", "Statistics about this site",
  238. // misc (142)
  239. "amag",  "German Amiga Mag PD",
  240. "antiq", "Nostalgic stuff",
  241. "edu",   "Educational software",
  242. "emu",   "Emulations",
  243. "imdb",  "Internet Movie Database",
  244. "kids",  "Children's software",
  245. "math",  "Mathematics",
  246. "misc",  "Uncategorizable",
  247. "sci",   "Scientific software",
  248. "unix",  "Amiga related UNIX software",
  249. // mods (152)
  250. "32bit", "MP3s by 32bit choonz",
  251. "4mat",  "Mods by 4mat",
  252. "8voic", "8-voiced songs",
  253. "airon", "Mods by Airon",
  254. "alpma", "Mods by Johan Alpmar",
  255. "atmos", "Atmospheric music",
  256. "aweso", "Mods by Dr Awesome",
  257. "bhead", "Mods by Basehead",
  258. "bladr", "Mods by Black Dragon",
  259. "blk",   "Mods by Black Shadow",
  260. "blkha", "Mods by Blakkhar",
  261. "boing", "Boing collection",
  262. "boray", "Mods by Boray",
  263. "casef", "Mods by Case and Filippetto",
  264. "cato",  "Mods by Don Cato",
  265. "cels",  "Mods by Celsius",
  266. "chart", "Module hits",
  267. "chip",  "Mods without samples",
  268. "chrom", "Mods by Chromag",
  269. "chryl", "Mods by Chrylian",
  270. "clawz", "Mods by Clawz",
  271. "cloud", "Mods by Cloud",
  272. "crash", "Mods by Crash Noise Division",
  273. "crn",   "Mods by Corrosion",
  274. "ctp",   "Mods by Counterpoint",
  275. "cutc",  "Mods by Cutcreator",
  276. "darde", "Mods by Fredius Darde",
  277. "dean",  "Mods by Dean",
  278. "delor", "Mods by Delorean",
  279. "demo",  "Demo style music",
  280. "dizzy", "Mods by Dizzy",
  281. "dlusn", "Mods by D.Lusion",
  282. "doh",   "Mods by Doh",
  283. "dremr", "Mods by Dreamer",
  284. "dsx",   "Mods by DSX",
  285. "elbie", "Mods by Elbie",
  286. "emax",  "Mods by Emax",
  287. "ephnx", "Mods by Euphonix",
  288. "evrim", "Mods by Evrimsson",
  289. "exprt", "Mods by Expert",
  290. "facet", "Mods by Facet",
  291. "fby",   "Mods by Fabio Barzagli",
  292. "fermx", "Mods by Fermix",
  293. "fox2",  "Mods by TheFoxII",
  294. "funet", "Funet collection",
  295. "funk",  "Funky/jazzy mods",
  296. "hardc", "Hardcore techno",
  297. "hje",   "Mods by H.J. Ehrentraud",
  298. "huezo", "Mods by Huezo",
  299. "house", "House modules",
  300. "hw",    "Mods by Hillware",
  301. "inst",  "Instruments for modules",
  302. "instr", "Instrumental music",
  303. "jogei", "Mods by Jogeir Liljedahl",
  304. "jorma", "Mods by Da Jormas (techno)",
  305. "jungl", "Jungle/Breakbeat mods",
  306. "k4k",   "Mods by k4k",
  307. "kaa",   "Mods by Redd Kaa",
  308. "lead",  "Mods by Lead",
  309. "mark",  "Mods by Mark Salud",
  310. "maxym", "Mods by Maxym",
  311. "med",   "MED modules",
  312. "melod", "Melodic modules",
  313. "melom", "Mods by MeloManiac",
  314. "midi",  "Music in MIDI format",
  315. "misc",  "Miscellaneous songs",
  316. "mnc",   "Mods by Meanace",
  317. "mpg",   "Music in MPEG audio format",
  318. "mryo",  "Mods by Mr. Yo",
  319. "mvp",   "Mods by MoPlayaz",
  320. "ncase", "Mods by Nutcase",
  321. "neuro", "Neurodancer's modules",
  322. "nork",  "Mods by Nork",
  323. "ooze",  "Mods by Ooze",
  324. "otis",  "Mods by Otis",
  325. "panik", "Mods by Panik",
  326. "pdy",   "Mods by Prodigy",
  327. "pete",  "Mods by Pirate Pete",
  328. "piano", "Piano mods",
  329. "pop",   "Pop music",
  330. "pro",   "Protracker songs",
  331. "przk",  "Mods by Parsec",
  332. "punn",  "Mods by Punnik",
  333. "purg",  "Mods by Purgatory",
  334. "rated", "Misc rated modules",
  335. "rebel", "Mods by Rebel Riffs",
  336. "rock",  "Rock'n'Roll",
  337. "roz",   "Mods by Roz",
  338. "s3m",   "Multichannel s3m mods",
  339. "sbc",   "Modules by Substance",
  340. "sets",  "Module collections",
  341. "sidew", "Mods by Sidewinder",
  342. "slc",   "Mods by Slice",
  343. "slow",  "Slow, melodic modules",
  344. "smg",   "Modes by esemgy",
  345. "smpl",  "Sound samples",
  346. "sonor", "Mods by Sonority",
  347. "spark", "Mods by P.D. Spark",
  348. "stame", "Mods by Stamen",
  349. "synth", "Synthesizer modules",
  350. "techn", "Techno music",
  351. "toady", "Mods by Olivier Gonneau",
  352. "tranc", "Trance techno mods",
  353. "tp96",  "Mods from The Party 1996",
  354. "uns",   "Mods by UnIsOn",
  355. "voice", "Music with voices",
  356. "voy",   "Mods by Voyager",
  357. "wmr",   "Mods reviewed by WMR",
  358. "xceed", "Mods by X-Ceed (ex Snoopy)",
  359. "xm",    "Multichannel xm mods",
  360. // mus (259)
  361. "edit",  "Composing software",
  362. "midi",  "MIDI software",
  363. "misc",  "Miscellaneous",
  364. "play",  "Sound players",
  365. // pix (263)
  366. "3dani", "3D animations",
  367. "addic", "Pictures by 3DAddict",
  368. "anim",  "Animations",
  369. "art",   "Hand drawn imagery",
  370. "astro", "Astronomy pictures",
  371. "back",  "Workbench backdrop pictures",
  372. "bill",  "Bill Graham traces",
  373. "boot",  "Boot pictures",
  374. "clip",  "Clip art",
  375. "eps",   "Structured EPS images",
  376. "eric",  "Eric Schwartz anims",
  377. "fauna", "Animals",
  378. "fract", "Fractals",
  379. "gicon", "GlowIcons",
  380. "glenn", "Traces by Glenn J. Schworak",
  381. "guard", "Guardians traces",
  382. "heiko", "Traces by Heiko Popp",
  383. "icon",  "Workbench icons",
  384. "illu",  "Illustrations",
  385. "imagi", "Imagine traces",
  386. "irc",   "The people on IRC",
  387. "jake",  "The Ragtime Gallery",
  388. "jason", "Jason Brown illustration",
  389. "map",   "Images of maps",
  390. "mark",  "Traces by Markus Kuhnen",
  391. "misc",  "Miscellaneous images",
  392. "mpg",   "MPEG animations",
  393. "mwb",   "MagicWB icons",
  394. "nevil", "Pics by Neville Rolle",
  395. "nicon", "NewIcons",
  396. "park",  "Maps of US national parks",
  397. "real3", "Real3D traces",
  398. "sport", "Sports pictures",
  399. "textu", "Textures",
  400. "tp96",  "Pics from The Party 1996",
  401. "trace", "Raytraced pictures",
  402. "unrl",  "Animations by Unreal",
  403. "vehic", "Vehicle images",
  404. "views", "Scenery, countries",
  405. "wb",    "Example WB screens",
  406. "wfm",   "Artwork of William F. Maddock",
  407. // text (303)
  408. "bfont", "Bitmap font collection",
  409. "dtp",   "Desk top publishing",
  410. "edit",  "Editors",
  411. "font",  "Fonts of all formats and related too", // ..."ls"
  412. "hyper", "Hypertext tools",
  413. "ifont", "Intellifont collection",
  414. "misc",  "Misc text software",
  415. "pfont", "Postscript font collection",
  416. "print", "Printing tools",
  417. "show",  "Text displayers",
  418. "tex",   "TeX formatting package",
  419. // util (314)
  420. "app",   "Appicons, appwindows",
  421. "arc",   "Archivers",
  422. "batch", "Script software",
  423. "blank", "Screen blankers",
  424. "boot",  "Startup sequence software",
  425. "cdity", "Commodity type software",
  426. "cli",   "Command line interface",
  427. "conv",  "File conversion",
  428. "crypt", "Encryption tools",
  429. "dir",   "Directory utilities",
  430. "dtype", "Datatypes for OS 3.x",
  431. "gnu",   "GNU utilities",
  432. "libs",  "Libraries",
  433. "misc",  "Miscellaneous",
  434. "moni",  "System monitors",
  435. "mouse", "Mouse accelerators",
  436. "pack",  "Packers",
  437. "rexx",  "ARexx tools",
  438. "shell", "Shells",
  439. "sys",   "Common file replacements",
  440. "time",  "Clocks and timing",
  441. "virus", "Virus checkers",
  442. "wb",    "Workbench utilities"
  443. };
  444.  
  445. AGLOBAL void aminet1(void)
  446. {   ULONG i, j, temp;
  447.  
  448.     verynewwindow
  449.     (   AMINETWIDTH, AMINETHEIGHT,
  450.         "Report+: Aminet Readme Details",
  451.         BUTTONIDCMP | STRINGIDCMP | LISTVIEWIDCMP
  452.     );
  453.     if (fillwindows)
  454.     {   SetAPen(MainWindowPtr->RPort, 0);
  455.         RectFill(MainWindowPtr->RPort,  10, 148,  10 + 246, 148 + 84 - 1);
  456.         RectFill(MainWindowPtr->RPort, 268, 148, 268 + 362, 148 + 84 - 1);
  457.     }
  458.     OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_NEW,    NOSUB));
  459.     OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_OPEN,   NOSUB));
  460.     OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_SAVE,   NOSUB));
  461.     OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_SAVEAS, NOSUB));
  462.  
  463.     if (react)
  464.     {   if (!(gadgets[GID_2_TE1] = (struct Gadget *) NewObject(
  465.             TEXTEDITOR_GetClass(),    NULL,
  466.             GA_ID,                    GID_2_TE1,
  467.             GA_Left,                  392,
  468.             GA_Top,                    36,
  469.             GA_Width,                 238,
  470.             GA_Height,                 94,
  471.             GA_RelVerify,             TRUE,
  472.             GA_TEXTEDITOR_ExportWrap,  75,
  473.             TAG_END)
  474.         ))
  475.         {   rq("Can't create ReAction gadgets!");
  476.         }
  477.  
  478.         AddGList(MainWindowPtr, gadgets[GID_2_TE1], -1, -1, NULL);
  479.         RefreshGList(gadgets[GID_2_TE1], MainWindowPtr, NULL, -1);
  480.  
  481.         setgadget(392, 36, 238, 1, "Long description:", PLACETEXT_ABOVE);
  482.         TE21_Long = PrevGadPtr = (struct Gadget *) CreateGadget
  483.         (   TEXT_KIND,
  484.             PrevGadPtr,
  485.             &Gadget,
  486.             TAG_DONE
  487.         );
  488.     } else
  489.     {   setgadget(392, 36, 238, 12, "Long descrip_tion...", NULL);
  490.         BU99_TextEditor = PrevGadPtr = (struct Gadget *) CreateGadget
  491.         (   BUTTON_KIND,
  492.             PrevGadPtr,
  493.             &Gadget,
  494.             GT_Underscore, '_',
  495.             TAG_DONE
  496.         );
  497.     }
  498.  
  499.     setgadget(128, 24, 250, 12, "_Short:", NULL);
  500.     ST21_Short = PrevGadPtr = (struct Gadget *) CreateGadget
  501.     (   STRING_KIND,
  502.         PrevGadPtr,
  503.         &Gadget,
  504.         GTST_String,   &(aminet.amishort),
  505.         GTST_MaxChars, 40,
  506.         GA_TabCycle,   TRUE,
  507.         GA_Immediate,  TRUE,
  508.         GT_Underscore, '_',
  509.         TAG_DONE
  510.     );
  511.  
  512.     if ((!(aminet.uploader[0])) && readin("S:Report.sender"))
  513.     {   /* # Refer: <last>,<first> (<company> ,phone <phone>)<LF>
  514.            # Path: <email><LF>
  515.            # ReferID: <developer><LF> */
  516.  
  517.         offset = 0;
  518.         parse("# Refer: ");
  519.         parse(",");
  520.         parse(" (");
  521.         parse(" ,phone ");
  522.         parse(")\n# Path: ");
  523.         parse("\n# ReferID: ");
  524.         strcpy(aminet.uploader, string);
  525.     }
  526.  
  527.     setgadget(128, 36, 250, 12, "_Uploader:", NULL);
  528.     ST21_Uploader = PrevGadPtr = (struct Gadget *) CreateGadget
  529.     (   STRING_KIND,
  530.         PrevGadPtr,
  531.         &Gadget,
  532.         GTST_String, &(aminet.uploader),
  533.         GTST_MaxChars, 40,
  534.         GA_TabCycle, TRUE,
  535.         GA_Immediate, TRUE,
  536.         GT_Underscore, '_',
  537.         TAG_DONE
  538.     );
  539.  
  540.     setgadget(128, 48, 250, 12, "_Author:", NULL);
  541.     ST21_Author = PrevGadPtr = (struct Gadget *) CreateGadget
  542.     (    STRING_KIND,
  543.     PrevGadPtr,
  544.     &Gadget,
  545.         GTST_String, &(aminet.author),
  546.     GTST_MaxChars, 40,
  547.     GA_TabCycle, TRUE,
  548.     GA_Immediate, TRUE,
  549.         GT_Underscore, '_',
  550.     TAG_DONE
  551.     );
  552.  
  553.     setgadget(128, 60, 250, 12, "_Replaces:", NULL);
  554.     ST21_Replaces = PrevGadPtr = (struct Gadget *) CreateGadget
  555.     (   STRING_KIND,
  556.     PrevGadPtr,
  557.     &Gadget,
  558.         GTST_String, &(aminet.replaces),
  559.     GTST_MaxChars, 40,
  560.     GA_TabCycle, TRUE,
  561.     GA_Immediate, TRUE,
  562.         GT_Underscore, '_',
  563.     TAG_DONE
  564.     );
  565.  
  566.     setgadget(128, 72, 250, 12, "R_equires:", NULL);
  567.     ST21_Requires = PrevGadPtr = (struct Gadget *) CreateGadget
  568.     (    STRING_KIND,
  569.     PrevGadPtr,
  570.     &Gadget,
  571.         GTST_String, &(aminet.requires),
  572.     GTST_MaxChars, 40,
  573.     GA_TabCycle, TRUE,
  574.     GA_Immediate, TRUE,
  575.         GT_Underscore, '_',
  576.     TAG_DONE
  577.     );
  578.  
  579.     setgadget(128, 84, 250, 12, "_Version:", NULL);
  580.     ST21_Version = PrevGadPtr = (struct Gadget *) CreateGadget
  581.     (   STRING_KIND,
  582.     PrevGadPtr,
  583.     &Gadget,
  584.         GTST_String, &(aminet.version),
  585.     GTST_MaxChars, 40,
  586.     GA_TabCycle, TRUE,
  587.     GA_Immediate, TRUE,
  588.         GT_Underscore, '_',
  589.     TAG_DONE
  590.     );
  591.  
  592.     setgadget(128, 98, 250, 12, "_Distribution:", NULL);
  593.     ST21_Distribution = PrevGadPtr = (struct Gadget *) CreateGadget
  594.     (    STRING_KIND,
  595.     PrevGadPtr,
  596.     &Gadget,
  597.         GTST_String, &(aminet.distribution),
  598.     GTST_MaxChars, 40,
  599.     GA_TabCycle, TRUE,
  600.     GA_Immediate, TRUE,
  601.         GT_Underscore, '_',
  602.     TAG_DONE
  603.     );
  604.  
  605.     if (!(MainTypeListPtr = AllocMem(sizeof(struct List), MEMF_CLEAR)))
  606.         rq("Out of memory!");
  607.     NewList(MainTypeListPtr);
  608.     for (i = 0; i <= MAINTYPES; i++)
  609.     {   strcpy(string, category[i].name);
  610.         temp = 4 - strlen(category[i].name);
  611.         for (j = 1; j <= temp; j++)
  612.             strcat(string, " ");
  613.         strcat(string, " ");
  614.         strcat(string, category[i].desc);
  615.         AddNameToTail(MainTypeListPtr, string);
  616.     }
  617.     setgadget(10, 148, 246, 84, "Directory:", NULL);
  618.     LV21_MainType = PrevGadPtr = (struct Gadget *) CreateGadget
  619.     (   LISTVIEW_KIND,
  620.         PrevGadPtr,
  621.         &Gadget,
  622.         GTLV_Labels, MainTypeListPtr,
  623.         GTLV_ShowSelected, NULL,
  624.         GTLV_Selected, aminet.maintype,
  625.         TAG_DONE
  626.     );
  627.  
  628.     if (!(SubTypeListPtr = AllocMem(sizeof(struct List), MEMF_CLEAR)))
  629.         rq("Out of memory!");
  630.     NewList(SubTypeListPtr);
  631.     for (i = offsets[aminet.maintype].start; i <= offsets[aminet.maintype].end; i++)
  632.     {   strcpy(string, category[i].name);
  633.         temp = 5 - strlen(category[i].name);
  634.         for (j = 1; j <= temp; j++)
  635.             strcat(string, " ");
  636.         strcat(string, " ");
  637.         strcat(string, category[i].desc);
  638.         AddNameToTail(SubTypeListPtr, string);
  639.     }
  640.     setgadget(268, 148, 362, 84, "Subdirectory:", NULL);
  641.     LV21_SubType = PrevGadPtr = (struct Gadget *) CreateGadget
  642.     (   LISTVIEW_KIND,
  643.         PrevGadPtr,
  644.         &Gadget,
  645.         GTLV_Labels, SubTypeListPtr,
  646.         GTLV_ShowSelected, NULL,
  647.         GTLV_Selected, aminet.subtype,
  648.         TAG_DONE
  649.     );
  650.  
  651.     drawgadgets((UWORD) ~0);
  652.     SetGadgetAttrs
  653.     (   gadgets[GID_2_TE1],     MainWindowPtr, NULL,
  654.         GA_TEXTEDITOR_Contents, aminet.textfield
  655.     ); // long description
  656.     ActivateGadget(ST21_Short, MainWindowPtr, NULL);
  657.     loop();
  658.  
  659.     readaminetgadgets();
  660.     if (react)
  661.     {   RemoveGList(MainWindowPtr, gadgets[GID_2_TE1], -1);
  662.         DisposeObject(gadgets[GID_2_TE1]);
  663.     }
  664.     closewindow();
  665.     // now that the window is closed we can free lists
  666.     aminet_exit();
  667. }
  668.  
  669. AGLOBAL void saveaminet(ABOOL saveas)
  670. {   /*  Short:        <short>
  671.         Uploader:     <uploader>
  672.         Author:       <author>
  673.         Type:         <type>
  674.         Replaces:     <replaces>
  675.         Requires:     <requires>
  676.         Version:      <version>
  677.         Distribution: <distribution>
  678.         
  679.         <long description> */
  680.  
  681.     readaminetgadgets();
  682.  
  683.     strcpy(IOBuffer, "Short:        ");
  684.     strcat(IOBuffer, aminet.amishort);
  685.     strcat(IOBuffer, "\n");
  686.     if (aminet.uploader[0])
  687.     {    strcat(IOBuffer, "Uploader:     ");
  688.             strcat(IOBuffer, aminet.uploader);
  689.         strcat(IOBuffer, "\n");
  690.     }
  691.     if (aminet.author[0])
  692.     {   strcat(IOBuffer, "Author:       ");
  693.         strcat(IOBuffer, aminet.author);
  694.         strcat(IOBuffer, "\n");
  695.     }
  696.     // it's compulsory to select a type
  697.     strcat(IOBuffer, "Type:         ");
  698.     strcat(IOBuffer, aminet.type);
  699.     strcat(IOBuffer, "\n");
  700.     if (aminet.replaces[0])
  701.     {   strcat(IOBuffer, "Replaces:     ");
  702.         strcat(IOBuffer, aminet.replaces);
  703.         strcat(IOBuffer, "\n");
  704.     }
  705.     if (aminet.requires[0])
  706.     {   strcat(IOBuffer, "Requires:     ");
  707.         strcat(IOBuffer, aminet.requires);
  708.         strcat(IOBuffer, "\n");
  709.     }
  710.     if (aminet.version[0])
  711.     {   strcat(IOBuffer, "Version:      ");
  712.         strcat(IOBuffer, aminet.version);
  713.         strcat(IOBuffer, "\n");
  714.     }
  715.     if (aminet.distribution[0])
  716.     {   strcat(IOBuffer, "Distribution: ");
  717.         strcat(IOBuffer, aminet.distribution);
  718.         strcat(IOBuffer, "\n");
  719.     }
  720.     strcat(IOBuffer, "\n");
  721.     strcat(IOBuffer, aminet.textfield);
  722.  
  723.     if (!aminet.output[0] || saveas) // if we need a filename
  724.     {   if (saveasl("Save Aminet Readme"))
  725.         {   strcpy(aminet.output, aslresult);
  726.             writeout(aminet.output);
  727. }   }   }
  728.  
  729. AGLOBAL void aminet_exit(void)
  730. {   if (SubTypeListPtr)
  731.     {   FreeNameNodes(SubTypeListPtr);
  732.         FreeMem(SubTypeListPtr, sizeof(struct List));
  733.         SubTypeListPtr = NULL;
  734.     }
  735.     if (MainTypeListPtr)
  736.     {   FreeNameNodes(MainTypeListPtr);
  737.         FreeMem(MainTypeListPtr, sizeof(struct List));
  738.         MainTypeListPtr = NULL;
  739. }   }
  740.  
  741. AGLOBAL void aminet_loop(ULONG class, struct Gadget* addr, UWORD code)
  742. {   ULONG i, j, temp;
  743.  
  744.     if (class == IDCMP_GADGETUP)
  745.     {   if (addr == BU99_Right)
  746.         {   page = 0;
  747.         } elif (addr == BU99_TextEditor)
  748.         {   saveaminet(FALSE);
  749.             launcheditor(aminet.output);
  750.         } elif (addr == LV21_MainType)
  751.         {   /* code is the position within the list, starting from 0. */
  752.             aminet.maintype = code;
  753.             aminet.subtype  = 0;
  754.  
  755.             // detach sublistview gadget
  756.             GT_SetGadgetAttrs
  757.             (   LV21_SubType,
  758.                 MainWindowPtr, NULL,
  759.                 GTLV_Labels, (UWORD) ~0,
  760.                 TAG_DONE
  761.             );
  762.             // free the current sublist
  763.             FreeNameNodes(SubTypeListPtr);
  764.             // now set up a new sublist
  765.             NewList(SubTypeListPtr);
  766.             for (i = offsets[aminet.maintype].start; i <= offsets[aminet.maintype].end; i++)
  767.             {   strcpy(string, category[i].name);
  768.                 temp = 5 - strlen(category[i].name);
  769.                 for (j = 1; j <= temp; j++)
  770.                     strcat(string, " ");
  771.                 strcat(string, " ");
  772.                 strcat(string, category[i].desc);
  773.                 AddNameToTail(SubTypeListPtr, string);
  774.             }
  775.             GT_SetGadgetAttrs
  776.             (   LV21_SubType,
  777.                 MainWindowPtr, NULL,
  778.                 GTLV_Labels, SubTypeListPtr,
  779.                 GTLV_Selected, aminet.subtype,
  780.                 TAG_DONE
  781.             );
  782.         } elif (addr == LV21_SubType)
  783.         {   aminet.subtype = code;
  784.     }   }
  785.     elif (class == IDCMP_VANILLAKEY)
  786.     {   code = toupper(code);
  787.         if (code == ESCAPE)
  788.         {   page = 0;
  789.         } elif (code == 'S')
  790.         {   ActivateGadget(ST21_Short, MainWindowPtr, NULL);
  791.         } elif (code == 'A')
  792.         {   ActivateGadget(ST21_Author, MainWindowPtr, NULL);
  793.         } elif (code == 'U')
  794.         {   ActivateGadget(ST21_Uploader, MainWindowPtr, NULL);
  795.         } elif (code == 'R')
  796.         {   ActivateGadget(ST21_Replaces, MainWindowPtr, NULL);
  797.         } elif (code == 'E')
  798.         {   ActivateGadget(ST21_Requires, MainWindowPtr, NULL);
  799.         } elif (code == 'V')
  800.         {   ActivateGadget(ST21_Version, MainWindowPtr, NULL);
  801.         } elif (code == 'D')
  802.         {   ActivateGadget(ST21_Distribution, MainWindowPtr, NULL);
  803.         } elif (code == 'T')
  804.         {   saveaminet(FALSE);
  805.             launcheditor(aminet.output);
  806. }   }   }
  807.  
  808. AGLOBAL void newaminet(ABOOL display)
  809. {   aminet.amishort[0]     =
  810.     aminet.uploader[0]     =
  811.     aminet.author[0]       =
  812.     aminet.requires[0]     =
  813.     aminet.distribution[0] =
  814.     aminet.type[0]         =
  815.     aminet.replaces[0]     =
  816.     aminet.output[0]       =
  817.     aminet.textfield[0]    =
  818.     aminet.maintype        =
  819.     aminet.subtype         = 0;
  820.     aminet.loaded          = FALSE;
  821.     strcpy(aminet.version, "1.0");
  822.  
  823.     if (display)
  824.         updateaminetgadgets();
  825. }
  826.  
  827. AGLOBAL void openaminet(void)
  828. {   if (asl())
  829.     {   loadaminet();
  830.         updateaminetgadgets();
  831. }   }
  832.  
  833. AGLOBAL void loadaminet(void)
  834. {   ABOOL done = FALSE;
  835.     ULONG i, j, slashpos = 0;
  836.     TEXT  tempstring[13];
  837.  
  838.     if (readin(aslresult))
  839.     {   strcpy(aminet.output, aslresult);
  840.         aminet.loaded = TRUE;
  841.         offset = 0;
  842.  
  843.         do
  844.         {   parse("\n");
  845.             if (string[0] == 0)
  846.             {   done = TRUE;
  847.                 parsetoend();
  848.                 strcpy(aminet.textfield, string);
  849.             } elif (!strncmp(string, "Short:",         6))
  850.             {   for (i =  6; i < strlen(string); i++)
  851.                 {   if (string[i] != ' ')
  852.                     {   strcpy(aminet.amishort,     &string[i]);
  853.                         break;
  854.             }   }   }
  855.             elif (!strncmp(string, "Uploader:",      9))
  856.             {   for (i =  9; i < strlen(string); i++)
  857.                 {   if (string[i] != ' ')
  858.                     {   strcpy(aminet.uploader,     &string[i]);
  859.                         break;
  860.             }   }   }
  861.             elif (!strncmp(string, "Author:",        7))
  862.             {   for (i =  7; i < strlen(string); i++)
  863.                 {   if (string[i] != ' ')
  864.                     {   strcpy(aminet.author,       &string[i]);
  865.                         break;
  866.             }   }   }
  867.             elif (!strncmp(string, "Type:",          5))
  868.             {   for (i =  5; i < strlen(string); i++)
  869.                 {   if (string[i] != ' ')
  870.                     {   strcpy(aminet.type,         &string[i]);
  871.                         while (aminet.type[slashpos] != '/')
  872.                         {   slashpos++;
  873.                         }
  874.                         // slashpos is now offset of '/'
  875.                         strncpy(tempstring, aminet.type, slashpos);
  876.                         tempstring[slashpos] = 0;
  877.                         for (j = 0; j <= MAINTYPES; j++)
  878.                         {   if (!strcmp(tempstring, category[j].name))
  879.                             {   aminet.maintype = j;
  880.                                 break;
  881.                         }   }
  882.                         slashpos++;
  883.                         for (j = offsets[aminet.maintype].start; j <= offsets[aminet.maintype].end; j++)
  884.                         {   if (!strcmp(&aminet.type[slashpos], category[j].name))
  885.                             {   aminet.subtype = j - offsets[aminet.maintype].start;
  886.                                 break;
  887.                         }   }
  888.                         break;
  889.             }   }   }
  890.             elif (!strncmp(string, "Replaces:",      9))
  891.             {   for (i =  9; i < strlen(string); i++)
  892.                 {   if (string[i] != ' ')
  893.                     {   strcpy(aminet.replaces,     &string[i]);
  894.                         break;
  895.             }   }   }
  896.             elif (!strncmp(string, "Requires:",      9))
  897.             {   for (i =  9; i < strlen(string); i++)
  898.                 {   if (string[i] != ' ')
  899.                     {   strcpy(aminet.requires,     &string[i]);
  900.                         break;
  901.             }   }   }
  902.             elif (!strncmp(string, "Version:",       8))
  903.             {   for (i =  8; i < strlen(string); i++)
  904.                 {   if (string[i] != ' ')
  905.                     {   strcpy(aminet.version,      &string[i]);
  906.                         break;
  907.             }   }   }
  908.             elif (!strncmp(string, "Distribution:", 13))
  909.             {   for (i = 13; i < strlen(string); i++)
  910.                 {   if (string[i] != ' ')
  911.                     {   strcpy(aminet.distribution, &string[i]);
  912.                         break;
  913.         }   }   }   }
  914.         while (!done);
  915. }   }
  916.  
  917. MODULE void updateaminetgadgets(void)
  918. {   ULONG i, j, temp;
  919.  
  920.     GT_SetGadgetAttrs
  921.     (   ST21_Short,
  922.         MainWindowPtr,
  923.         NULL,
  924.         GTST_String, aminet.amishort,
  925.         TAG_DONE
  926.     );
  927.     GT_SetGadgetAttrs
  928.     (   ST21_Uploader,
  929.         MainWindowPtr,
  930.         NULL,
  931.         GTST_String, aminet.uploader,
  932.         TAG_DONE
  933.     );
  934.     GT_SetGadgetAttrs
  935.     (   ST21_Author,
  936.         MainWindowPtr,
  937.         NULL,
  938.         GTST_String, aminet.author,
  939.         TAG_DONE
  940.     );
  941.     GT_SetGadgetAttrs
  942.     (   ST21_Requires,
  943.         MainWindowPtr,
  944.         NULL,
  945.         GTST_String, aminet.requires,
  946.         TAG_DONE
  947.     );
  948.     GT_SetGadgetAttrs
  949.     (   ST21_Version,
  950.         MainWindowPtr,
  951.         NULL,
  952.         GTST_String, aminet.version,
  953.         TAG_DONE
  954.     );
  955.     GT_SetGadgetAttrs
  956.     (   ST21_Distribution,
  957.         MainWindowPtr,
  958.         NULL,
  959.         GTST_String, aminet.distribution,
  960.         TAG_DONE
  961.     );
  962.     GT_SetGadgetAttrs
  963.     (   ST21_Replaces,
  964.         MainWindowPtr,
  965.         NULL,
  966.         GTST_String, aminet.replaces,
  967.         TAG_DONE
  968.     );
  969.  
  970.     GT_SetGadgetAttrs
  971.     (   LV21_MainType,
  972.         MainWindowPtr, NULL,
  973.         GTLV_Selected, aminet.maintype,
  974.         TAG_DONE
  975.     );
  976.  
  977.     // detach sublistview gadget
  978.     GT_SetGadgetAttrs
  979.     (   LV21_SubType,
  980.         MainWindowPtr, NULL,
  981.         GTLV_Labels, (UWORD) ~0,
  982.         TAG_DONE
  983.     );
  984.     // free the current sublist
  985.     FreeNameNodes(SubTypeListPtr);
  986.     // now set up a new sublist
  987.     NewList(SubTypeListPtr);
  988.     for (i = offsets[aminet.maintype].start; i <= offsets[aminet.maintype].end; i++)
  989.     {   strcpy(string, category[i].name);
  990.         temp = 5 - strlen(category[i].name);
  991.         for (j = 1; j <= temp; j++)
  992.             strcat(string, " ");
  993.         strcat(string, " ");
  994.         strcat(string, category[i].desc);
  995.         AddNameToTail(SubTypeListPtr, string);
  996.     }
  997.     // The following two calls must be separate and in order.
  998.     GT_SetGadgetAttrs
  999.     (   LV21_SubType,
  1000.         MainWindowPtr, NULL,
  1001.         GTLV_Labels, SubTypeListPtr,
  1002.         TAG_DONE
  1003.     );
  1004.     GT_SetGadgetAttrs
  1005.     (   LV21_SubType,
  1006.         MainWindowPtr, NULL,
  1007.         GTLV_Selected, aminet.subtype,
  1008.         TAG_DONE
  1009.     );
  1010.  
  1011.     if (react)
  1012.     {   SetGadgetAttrs
  1013.         (   gadgets[GID_2_TE1], MainWindowPtr, NULL,
  1014.             GA_TEXTEDITOR_Contents, aminet.textfield,
  1015.             TAG_DONE
  1016.         );
  1017. }   }
  1018.  
  1019. MODULE void readaminetgadgets(void)
  1020. {   STRPTR textBuffer;
  1021.  
  1022.     strcpy
  1023.     (   aminet.amishort,
  1024.         ((struct StringInfo *) ST21_Short->SpecialInfo)->Buffer
  1025.     );
  1026.     strcpy
  1027.     (   aminet.uploader,
  1028.         ((struct StringInfo *) ST21_Uploader->SpecialInfo)->Buffer
  1029.     );
  1030.     strcpy
  1031.     (   aminet.author,
  1032.         ((struct StringInfo *) ST21_Author->SpecialInfo)->Buffer
  1033.     );
  1034.     strcpy
  1035.     (   aminet.replaces,
  1036.         ((struct StringInfo *) ST21_Replaces->SpecialInfo)->Buffer
  1037.     );
  1038.     strcpy
  1039.     (   aminet.requires,
  1040.         ((struct StringInfo *) ST21_Requires->SpecialInfo)->Buffer
  1041.     );
  1042.     strcpy
  1043.     (   aminet.version,
  1044.         ((struct StringInfo *) ST21_Version->SpecialInfo)->Buffer
  1045.     );
  1046.     strcpy
  1047.     (   aminet.distribution,
  1048.         ((struct StringInfo *) ST21_Distribution->SpecialInfo)->Buffer
  1049.     );
  1050.     strcpy(aminet.type, category[aminet.maintype].name);
  1051.     strcat(aminet.type, "/");
  1052.     strcat(aminet.type, category[offsets[aminet.maintype].start + aminet.subtype].name);
  1053.  
  1054.     if (react)
  1055.     {   textBuffer = (STRPTR) DoGadgetMethod(gadgets[GID_2_TE1], MainWindowPtr, NULL, GM_TEXTEDITOR_ExportText, NULL);
  1056.         strcpy(aminet.textfield, textBuffer); // long description
  1057.         FreeVec((APTR) textBuffer);
  1058.         // textBuffer = NULL;
  1059. }   }
  1060.